package com.fduss.mazegame.client.tui;

import com.fduss.mazegame.CLOptions;
import com.fduss.mazegame.client.MsgToUsr;
import com.fduss.mazegame.server.StoryServer;

/**
 * a simple tui for story mode
 *
 * @author Duocai Wu
 * @Date 2017/10/18
 * @Time 15:48
 */

public class StoryTui extends Tui {
    public StoryTui(CLOptions options) {
        super(options);
        // override the server
        server = new StoryServer(options.getServerSpec());
    }

    @Override
    public void run() {
        showWelcomeMess();
        // start game;
        StoryServer storyServer = (StoryServer) server;
        int levelNum = storyServer.getLevelNum();
        for (int i = 0; i < levelNum; i++) {
            storyServer.initLevel(i);
            System.out.println(String.format(
                    localizer.get(MsgToUsr.LEVEL_START),
                    (i + 1)
            ));
            startGameLoop();
            if (!storyServer.isHeroAlive())
                System.exit(0);
        }
        System.out.println(localizer.get(MsgToUsr.PASS_ALL_LEVEL));
    }
}
